package com.xgkj.diyiketang.util.xiangce;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by windo on 16/4/13.
 */
public class PhotoFolderInfo implements Parcelable,Comparable<PhotoFolderInfo>{
    public int count = 0;
    public String folderName;
    public List<PhotoImageInfo> imageList;

    public static final Creator<PhotoFolderInfo> CREATOR = new Creator<PhotoFolderInfo>() {
        @Override
        public PhotoFolderInfo createFromParcel(Parcel in) {
            PhotoFolderInfo info = new PhotoFolderInfo();
            info.count = in.readInt();
            info.folderName = in.readString();
            info.imageList = new ArrayList<PhotoImageInfo>();
            in.readList(info.imageList,PhotoImageInfo.class.getClassLoader());
            return info;
        }

        @Override
        public PhotoFolderInfo[] newArray(int size) {
            return new PhotoFolderInfo[size];
        }
    };

    @Override
    public int compareTo(PhotoFolderInfo another) {
        if (another == null)return 0;
        int myImageId = imageList.get(0).imageId;
        int anotherImageId = another.imageList.get(0).imageId;
        if (myImageId >anotherImageId){
            return -1;
        }else if (myImageId<anotherImageId){
            return 1;
        }
        return 0;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(count);
        dest.writeString(folderName);
        dest.writeList(imageList);
    }
}
